package com.ibeeking.found.org.b.rest.controller.v1;

import com.ibeeking.found.org.b.rest.service.IOrgJobService;
import com.ibeeking.found.org.service.common.param.OrgJobParam;

import com.ibeeking.found.org.service.common.query.OrgJobQuery;
import com.ibeeking.found.org.service.common.vo.JobLevelVO;
import com.ibeeking.found.org.service.common.vo.OrgJobVO;
import com.ibeeking.nematos.constants.enums.OperateLogTypeEnum;
import com.ibeeking.nematos.log.annotation.Log;
import com.ibeeking.nematos.utils.base.BaseValidationGroup;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName OrgJobController
 * @Description
 * @Author ibeeking
 * @Date 2021-01-29 14:48
 **/
@RestController
@RequestMapping("/b/job/v1")
public class OrgJobController {

    @Resource
    private IOrgJobService orgJobServiceImpl;

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "职位列表")
    @PostMapping(value = "/list")
    public List<OrgJobVO> list(@RequestBody OrgJobQuery query) {
        return orgJobServiceImpl.list(query);
    }

    @Log(logType = OperateLogTypeEnum.SAVE, describe = "职位添加")
    @PostMapping(value = "/add")
    public Boolean add(@RequestBody @Validated(BaseValidationGroup.Insert.class) OrgJobParam param) {
        return orgJobServiceImpl.add(param);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "职位修改")
    @PostMapping(value = "/modify")
    public Boolean modify(@RequestBody @Validated(BaseValidationGroup.Update.class) OrgJobParam param) {
        return orgJobServiceImpl.modify(param);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "职位查看")
    @GetMapping(value = "/view/{id}")
    public OrgJobVO view(@PathVariable("id") Long id) {
        return orgJobServiceImpl.view(id);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "职位状态修改")
    @GetMapping(value = "/changeStatus/{id}/{status}")
    public Boolean changeStatus(@PathVariable("id") Long id, @PathVariable("status") Integer status) {
        return orgJobServiceImpl.changeStatus(id, status);
    }

    @Log(logType = OperateLogTypeEnum.DEL, describe = "职位删除")
    @GetMapping(value = "/del/{id}")
    public Boolean del(@PathVariable("id") Long id) {
        return orgJobServiceImpl.del(id);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "职级列表")
    @GetMapping(value = "/jobLevelList")
    public List<JobLevelVO> jobLevelList() {
        return orgJobServiceImpl.jobLevelList();
    }

}